#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include "cmd.h"

void exec_cmd(struct cmd *cmd)
{
    pid_t pid=fork();
    if(pid < 0) {
        perror("fork");
        exit(EXIT_FAILURE);
    }
    else if(pid == 0) {
        execvp(cmd->argv[0],cmd->argv);
        perror("exec");
        exit(EXIT_FAILURE);
    } else {
        int status;
        if (waitpid(pid, &status, 0) < 0) {
            perror("waitpid");
        }
    }
}

